package com.saret.crawler.startup;

import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.saret.crawler.Crawler;
import com.saret.crawler.search.BingWebSearch;
import com.saret.crawler.search.WebSearch;
import com.saret.utils.BindUtil;
import com.saret.utils.FileLocator;

import java.io.IOException;

/**
 * User: biniam.gebremichael
 * Date: 2/3/11
 */
public class LoadCrawler {

    private static final Module[] modules = {
            new Module() {

                @Override
                public void configure(Binder binder) {
                    BindUtil.bindProperties(binder, FileLocator.getConfigFile("crawler", "tiCrawler.properties"));
                    BindUtil.bindProperties(binder, FileLocator.getConfigFile("project.properties"));

                    binder.bind(WebSearch.class).to(BingWebSearch.class);
                    binder.bind(Crawler.class).asEagerSingleton();
                }
            }
    };

    public static void main(String[] args) throws IOException {

        Injector injector = Guice.createInjector(modules);
        Crawler crawler = injector.getInstance(Crawler.class);
        crawler.crawl();
    }
}
